package com.deng.performance.first.view
{
	import com.deng.performance.first.vo.OrganizationFirstBonusVo;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	import mx.controls.TextInput;
	import mx.events.FlexEvent;
	import mx.resources.ResourceManager;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;

	public class OrganizationPutValueTI extends TextInput
	{
		private var selVo:OrganizationFirstBonusVo;
		public function OrganizationPutValueTI()
		{
			this.addEventListener(FlexEvent.CREATION_COMPLETE,showHandler);
			this.addEventListener(MouseEvent.MOUSE_UP,upEvt);
			this.addEventListener(FlexEvent.SHOW,showHandler);
			super();
			this.restrict = "0-9.";
		}
		private function upEvt(event:MouseEvent):void{			
			var ro:RemoteObject = new RemoteObject();
			ro.destination = "EmployeeImpl";			
			ro.addEventListener(FaultEvent.FAULT,flt);
			ro.addEventListener(ResultEvent.RESULT,updateRst);
//			if(this.selected){//之前选中的，后面要删除
//				ro.setEmployeeInuse(selVo,0);
//				selVo.in_use = 0;
//			}else{//之前没选中，后面要增加
//				ro.setEmployeeInuse(selVo,1);
//				selVo.in_use = 1;	
//			}			
		}
		private function updateRst(evt:ResultEvent):void{
			Alert.show(ResourceManager.getInstance().getString("lang", "update_success"));
//			var rtEvt:ReturnEvent=new ReturnEvent(ReturnEvent.loadDispenseManagerList);
//			rtEvt.dispatch();
		}
		private function flt(evt:FaultEvent):void{
			Alert.show(evt.fault.getStackTrace());
		}
		private function showHandler(evt:FlexEvent):void{
			selVo = this.data as OrganizationFirstBonusVo;
			this.text = selVo.put_value;
		}
	}
}